package com.engine4cloud.tdf.education.controller.inner;

import com.engine4cloud.tdf.common.core.util.R;
import com.engine4cloud.tdf.common.data.web.response.PageInfo;
import com.engine4cloud.tdf.common.security.annotation.Inner;
import com.engine4cloud.tdf.education.dto.query.EduStudentTaskAppQueryDTO;
import com.engine4cloud.tdf.education.dto.result.EduStudyTaskResultDTO;
import com.engine4cloud.tdf.education.service.EduStudyTaskService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;

/**
 * 学生学习任务-inner
 *
 * @author wenjie
 * @date 2024-08-15 15:06:54
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/inner/student/task/record")
@Tag(description = "eduStudentTask", name = "学生学习任务-inner")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class EduStudentTaskInnerController {

    private final EduStudyTaskService studyTaskService;

    /**
     * 矫正对象学习记录列表
     *
     * @param dto 学习记录表
     * @return R<PageInfo < EduLearningRecordResultDTO>>
     */
    @Inner
    @Operation(summary = "分页查询", description = "分页查询")
    @PostMapping("/page")
    public R<PageInfo<EduStudyTaskResultDTO>> pageList(@Valid @RequestBody EduStudentTaskAppQueryDTO dto) {
        return R.ok(studyTaskService.pageList(dto));
    }

    /**
     * 通过id查询学习记录表
     *
     * @param id id
     * @return R
     */
    @Inner
    @Operation(summary = "通过id查询", description = "通过id查询")
    @GetMapping("/{id}")
    public R<EduStudyTaskResultDTO> getById(@PathVariable("id") Long id) {
        return R.ok(studyTaskService.getById(id));
    }
}